package com.zlq.web.controller;

import com.zlq.web.pojo.User;
import com.zlq.web.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

@Controller
public class UserController {

    @Autowired
    private UserService userService;

    @RequestMapping(value = "/login")
    public String login(){
        return "login";
    }
    @RequestMapping(value = "/mainz")
    public String mainz(@RequestParam("userName") String userName, @RequestParam("password") String passWord){

        User user = new User();
        user.setUsername(userName);
        user.setPassword(passWord);
        System.out.println(userName);
        System.out.println(passWord);
        System.out.println(user.toString());

        if (userService.login(user))
            return "main";
        return  "login";
    }

//    @RequestMapping("/login")
//    public String login(@RequestParam("userName") String userName, @RequestParam("password") String passWord){
//        User user = new User();
//        user.setUsername(userName);
//        user.setPassword(passWord);
////        System.out.println(userName);
////        System.out.println(passWord);
////        System.out.println(user.toString());
//
//        if (userService.login(user))
//            return "main";
//        return  "login";
//
//    }
}
